{include file="common/header"/}
<div class="lemo-container">
    <div class="lemo-main">
        <fieldset class="layui-elem-field layui-field-title">
            <legend>题目{:lang('list')}</legend>
            <blockquote class="layui-elem-quote">
                <div class="lemo-table">
<!--                    <div class="layui-inline">-->
<!--                        <input type="text" id='keys' name="keys" lay-verify="required"-->
<!--                               placeholder="{:lang('pleaseEnter')}" autocomplete="off" class="layui-input">-->
<!--                    </div>-->
<!--                    <a href="javascript:;" class="layui-btn data-add-btn layui-btn-sm" lay-submit="" lay-filter="add"-->
<!--                       id="search">-->
<!--                        {:lang('search')}-->
<!--                    </a>-->

                    <form class="layui-form layui-form-pane" lay-filter="form" style="margin-top: 20px;">
                        <div class="layui-form-item" id="quiz">
                            <div class="layui-input-inline">
                                <select name="quiz1" lay-search="" lay-filter="quiz1">
                                    <option value="" selected>请选择系别</option>
                                    {volist name="gradeList" id="vo"}
                                    <option value="{$vo.id}">{$vo.title}</option>
                                    {/volist}
                                </select>
                            </div>

                            <div class="layui-input-inline">
                                <select name="quiz2" id="quiz2" lay-search="" lay-filter="quiz2">
                                    <option value="" disabled="" selected>请选择专业</option>
                                </select>
                            </div>

                            <div class="layui-input-inline">
                                <select name="quiz3" id="quiz3" lay-search="" lay-filter="quiz3">
                                    <option value="" disabled="" selected>请选择班级</option>
                                </select>
                            </div>
<!--                            <div class="layui-form-mid layui-word-aux">必须选择到班级</div>-->

                            <div class="layui-inline">
                                <button class="layui-btn layui-btn" lay-submit lay-filter="goods-search"><i
                                        class="iconfont icon-chaxun"></i>筛选
                                </button>
                            </div>
                        </div>



                    </form>

                    <!--                        <a data-href="{:url('add')}" class="layui-btn layui-btn-sm layui-btn-warm add">{:lang('add')}题目</a>-->
                    <!--                        <a href="javascript:;"  class="layui-btn layui-btn-sm layui-btn-danger" id="delAll">{:lang('delete checked')}</a>-->

                </div>
            </blockquote>

        </fieldset>

        <table class="layui-table" id="list" lay-filter="list"></table>
    </div>
</div>


<!--<script type="text/html" id="action">-->
<!--    <a data-href="{:url('edit')}?id={{d.id}}" class="layui-btn  layui-btn-xs" lay-event="edit">{:lang('edit')}</a>-->
<!--    <a  class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">{:lang('del')}</a>-->
<!--</script>-->
<script type="text/html" id="action">
    <a data-href="{:url('student_edit')}?id={{d.id}}" class="layui-btn layui-btn-xs" lay-event="edit">评价打分</a>
    <a data-href="{:url('schedule_list')}?id={{d.id}}" class="layui-btn layui-btn-xs layui-btn-warm" lay-event="edit">课程设计</a>
</script>

<script type="text/html" id="last_login">
    {{layui.util.toDateString(d.last_login*1000, 'yyyy-MM-dd HH:mm:ss')}}
</script>
<script type="text/html" id="create_time">
    {{layui.util.toDateString(d.create_time*1000, 'yyyy-MM-dd HH:mm:ss')}}
</script>
<!--<script type="text/html" id="update_time">-->
<!--    {{layui.util.toDateString(d.update_time*1000, 'yyyy-MM-dd HH:mm:ss')}}-->
<!--</script>-->

<script type="text/html" id="toolbar">
    <div class="layui-btn-container">
        <!--        <button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button>-->
        <!--        <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>-->
        <!--        <button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button>-->
    </div>
</script>
{include file="common/footer"/}
<script>
    var tableIn = null;
    layui.config({
        base: "/static/admin/js/",
        version: true
    }).extend({
        Admin: 'Admin',
    }).use(['table', 'Admin'], function () {
        var $ = layui.jquery,
            table = layui.table;


        tableIn = table.render({
            elem: '#list',
            url: '{:url("index")}',
            method: 'post',
            title: '用户数据表',
            toolbar: '#toolbar', //开启头部工具栏，并为其绑定左侧模板

            defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                , layEvent: 'LAYTABLE_TIPS'
                , icon: 'layui-icon-tips'
            }],
            cols: [[
                {checkbox: true, fixed: true},
                {field: 'id', title: 'ID', width: 80, type: 'numbers', fixed: true, sort: true},
                {field: 'username', title: '用户名', width: 120},
                {field: 'stucode', title: '学号', width: 200},
                {field: 'q1', title: '系别', width: 120},
                {field: 'q2', title: '专业', width: 120},
                {field: 'q3', title: '班级', width: 150},
                {field: 'grade', title: '总成绩', width: 100},
                // {field: 'evaluate', title: '评价', width: 400},
                {field: 'create_time', title: '创建时间', width: 180, templet: '#create_time'},
                // {field: 'update_time', title: '更新时间', width: 180,templet:'#update_time'},

                {title: '操作', width: 180, toolbar: '#action', align: "center"},

            ]],
            id: 'list_re',
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true
        });

        //这儿监听上面列表点击操作
        layui.form.on('select(quiz1)', function (data) {

            if (data.value == ''){
                console.log(11)
                // $('#quiz1').empty();
                $('#quiz2').empty();
                $('#quiz3').empty();
                return
            }

            $('#quiz2').empty()
            $('#quiz3').empty()

            $.ajax({
                url: "{:url('getZy')}",
                type: "POST",
                dataType: 'json',
                data: {id: data.value},
                success: function (res) {
                    dataLists = res.data
                    for (var i = 0; i < dataLists.length; i++) {
                        $('#quiz2').append("<option value=" + dataLists[i]['id'] + ">" + dataLists[i]['title'] + "</option>")
                    }
                    layui.form.render('select');
                }
            });
        });

        //这儿监听上面列表点击操作
        layui.form.on('select(quiz2)', function (data) {
            $('#quiz3').empty()

            $.ajax({
                url: "{:url('getBj')}",
                type: "POST",
                dataType: 'json',
                data: {id: data.value},
                success: function (res) {
                    dataLists = res.data
                    for (var i = 0; i < dataLists.length; i++) {
                        $('#quiz3').append("<option value=" + dataLists[i]['id'] + ">" + dataLists[i]['title'] + "</option>")
                    }
                    layui.form.render('select');

                }
            });
        });

        // 筛选
        layui.form.on('submit(goods-search)', function (data) {

            table.reload('list_re', {
                method: 'post',
                where: {
                    quiz1: data.field.quiz1,
                    quiz2: data.field.quiz2,
                    quiz3: data.field.quiz3,
                    keys: true
                },
                page: {
                    curr: 1,
                }
            })
            return false;
        });


    });


</script>